#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int n, sum;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	cin >> sum;
	sort(arr, arr + n);
	int i = 0;
	int j = n - 1;
	int ans = 0;
	while (i < j) {
		if (arr[i] + arr[j] == sum) {
			ans++;
			i++;
			j--;
		}
		else if (arr[i] + arr[j] > sum) {
			j--;
		}
		else {
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}